//! # Api - 给前端提供的 API
//!
//! 提供给前端的 API 接口。

use tauri::Runtime;

mod fop;
mod playlist;
mod window;

/// Tauri MP4Game Api 扩展
pub trait TauriMP4GameApi<R: Runtime> {
    /// 注册 MP4Game Api
    fn invoke_mp4game_handler(self) -> tauri::Builder<R>;
}

impl TauriMP4GameApi<tauri::Wry> for tauri::Builder<tauri::Wry> {
    /// 注册 MP4Game Api
    fn invoke_mp4game_handler(self) -> tauri::Builder<tauri::Wry> {
        self.invoke_handler(tauri::generate_handler![
            fop::glob,
            fop::glob_in_data,
            fop::read_json,
            fop::write_json,
            fop::remove_json,
            fop::rename_json,
            fop::open_data_folder,
            playlist::open,
            playlist::duration,
            playlist::play,
            playlist::convert,
            playlist::stop,
            playlist::close,
            window::set_window_theme,
            window::set_window_visibility,
            window::is_window_visible,
        ])
    }
}
